﻿using System;
using System.Collections.Generic;
using System.Text;

namespace efish.Framework.Model
{
    /// <summary>
    /// Summary description for Product
    /// </summary>
    public class Product : BaseModel
    {
        #region Basic info

        private string _title = "";
        public virtual string Title
        {
            get { return _title; }
            set { _title = value; }
        }

        private string _content;
        public virtual string Content
        {
            get { return _content; }
            set { _content = value; }
        }

        private DateTime _addedDate = DateTime.Now;
        public virtual DateTime AddedDate
        {
            get { return _addedDate; }
            set { _addedDate = value; }
        }

        private string _addedBy = "";
        public virtual string AddedBy
        {
            get { return _addedBy; }
            set { _addedBy = value; }
        }

        private int _categoryID = 0;
        public virtual int CategoryID
        {
            get { return _categoryID; }
            set { _categoryID = value; }
        }

        private string _sku = "";
        public virtual string SKU
        {
            get { return _sku; }
            set { _sku = value; }
        }

        private decimal _unitPrice = 0.0m;
        public virtual decimal UnitPrice
        {
            get { return _unitPrice; }
            set { _unitPrice = value; }
        }

        private int _discountPercentage = 0;
        public virtual int DiscountPercentage
        {
            get { return _discountPercentage; }
            set { _discountPercentage = value; }
        }

        private int _unitsInStock = 0;
        public virtual int UnitsInStock
        {
            get { return _unitsInStock; }
            set { _unitsInStock = value; }
        }
        
        private string _smallImageUrl = "";
        public virtual string SmallImageUrl
        {
            get { return _smallImageUrl; }
            set { _smallImageUrl = value; }
        }

        private string _fullImageUrl = "";
        public virtual string FullImageUrl
        {
            get { return _fullImageUrl; }
            set { _fullImageUrl = value; }
        }

        private int _votes = 0;
        public virtual int Votes
        {
            get { return _votes; }
            set { _votes = value; }
        }

        private int _totalRating = 0;
        public virtual int TotalRating
        {
            get { return _totalRating; }
            set { _totalRating = value; }
        }

        #endregion

        #region Customer Reviews

        private ICollection<Review> _reviews;
        public virtual ICollection<Review> Reviews
        {
            get
            {
                return _reviews;
            }
            set
            {
                _reviews = value;
            }
        } 

        #endregion

        #region Caculate Properties
        public virtual double AverageRating
        {
            get
            {
                if (this.Votes >= 1)
                    return ((double)this.TotalRating / (double)this.Votes);
                else
                    return 0.0;
            }
        }

        public virtual decimal FinalUnitPrice
        {
            get
            {
                if (this.DiscountPercentage > 0)
                    return this.UnitPrice - (this.UnitPrice * this.DiscountPercentage / 100);
                else
                    return this.UnitPrice;
            }
        }

        #endregion

        public virtual string Images
        {
            get { return null; }
            set { }
        }

        public virtual string Spec
        {
            get { return null; }
            set { }
        }
    }

    /// <summary>
    /// Summary description for Review
    /// </summary>
    public class Review : BaseModel
    {
        private string _title;
        public virtual string Title
        {
            get
            {
                return _title;
            }
            set
            {
                _title = value;
            }
        }

        private string _content;
        public virtual string Content
        {
            get
            {
                return _content;
            }
            set
            {
                _content = value;
            }
        }

        private DateTime _addedDate = DateTime.Now;
        public virtual DateTime AddedDate
        {
            get { return _addedDate; }
            set { _addedDate = value; }
        }

        private string _addedBy = "";
        public virtual string AddedBy
        {
            get { return _addedBy; }
            set { _addedBy = value; }
        }

        private string _addedByEmail = "";
        public virtual string AddedByEmail
        {
            get { return _addedByEmail; }
            set { _addedByEmail = value; }
        }

        private string _addedByIP = "";
        public virtual string AddedByIP
        {
            get { return _addedByIP; }
            set { _addedByIP = value; }
        }
        
        private int _rating = 0;
        public virtual int Rating
        {
            get { return _rating; }
            set { _rating = value; }
        }

        private int _productID;
        public virtual int ProductID
        {
            get { return _productID; }
            set { _productID = value; }
        }
    }

    /// <summary>
    /// Summary description for ManufacturerInfo
    /// </summary>
    public class ManufacturerInfo : BaseModel
    {
    }
}
